﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataAccessLayer;
using System.Configuration;
using System.Data;

namespace ABCComputer.DAL
{
    public class CommonDAL
    {
        private DBManager dbmanager;
        public CommonDAL()
        {
            string ConnectionInfo = ConfigurationManager.AppSettings["ConnectionInfo"];
            dbmanager = new DBManager(DataProvider.SqlServer, ConnectionInfo);
        }

        // lấy các giá trị quy định trong bảng tham số
        public int laySoLuotMuaGoiLaHot()
        {
            int soluotmua = 0;
            IDataReader reader = null;
            try
            {
                dbmanager.Open();

                reader = dbmanager.ExecuteReader(CommandType.Text, "select giatri from thamso where mathamso = 1");
                while(reader.Read())
                    soluotmua = Convert.ToInt32(reader["giatri"]);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (reader != null)
                    reader.Close();
                dbmanager.Close();
            }
            return soluotmua;
        }
    }
}